#pragma once
#include <deque>

#include "Message.hpp"

#define MAX_MSG_LENGTH 14
#define MAX_MSG_WIDTH 86

class MessageList{
  public:
    MessageList(int len = MAX_MSG_LENGTH, size_t width = MAX_MSG_WIDTH)
    :max_msg_lenth(len)
    ,max_msg_width(width)
    {}

    void PushMsg(std::string& msg){
      for(size_t i = 0; i < msg.size(); i += max_msg_width){
        FullPop();
        std::string tmp("\t");
        tmp += std::string(msg, i, max_msg_width);
        msg_list.push_back(tmp);
      }
    }

    void PushInfo(std::string& info){
      FullPop();
      msg_list.push_back(info);
    }

    void FullPop(){
      if(msg_list.size() == max_msg_lenth){
        msg_list.pop_front();
      }
    }

    std::deque<std::string>& ShowMsg(){
      return msg_list;
    }

    void Clear(){
      msg_list.clear();
    }
  private:
    size_t max_msg_lenth;
    size_t max_msg_width;
    std::deque<std::string> msg_list;
};
